Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
Why am I getting a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error on my site?

I was messing around with API's to gain familiarity with them, and I'm trying to display a list of object names from an API. But when I open my website, nothing is displayed and I get a CORS error. Here is my code:

const url = 'https://api.wynncraft.com/v2/ingredient/list';
const mainDiv = document.getElementById('container');
fetch(url)
.then((resp) => resp.json())
.then(function(data) {
 let ingredients = data.results;
 return ingredients.map(function(ingredient) {
     let li = createNode('li');
     let span = createNode('span');
     span.innerHTML = `${ingredient.name}`;
     append(li, span);
     append(ul, li);
 })
})
.catch(function(error) {
 console.log(error);
});

function createNode(element) {
 return document.createElement(element);
}

function append(parent, el) {
 return parent.appendChild(el);
}

And the associated HTML:

<!DOCTYPE html>
<html>
    <head>
        <title>Wynncraft API Test</title>
    </head>
    <body>
        <div id="container"></div>
        <script src="script.js"></script>
    </body>
</html>

Any help is greatly appreciated!

Error Code

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda